library(igraph)

set.seed(1)

nodes<-seq(1,50,1)

edgea<-matrix(nrow=50,ncol=2)
edgea[1:50,1]<-nodes

for (i in 3:25){
edgea[i,2]<-1
}

for (i in 26:50){
edgea[i,2]<-2
}

edgea[1,2]<-2
edgea[2,2]<-1

edgea <- data.frame(edgea)
ga <- graph.data.frame(edgea,directed=FALSE)
ga<-simplify(ga)

edgeb<-matrix(nrow=55,ncol=2)
edgeb[1:50,1]<-nodes

for (i in 6:14){
edgeb[i,2]<-1
}

for (i in 15:23){
edgeb[i,2]<-2
}

for (i in 24:32){
edgeb[i,2]<-3
}

for (i in 33:41){
edgeb[i,2]<-4
}

for (i in 41:50){
edgeb[i,2]<-5
}

edgeb[51,1]<-1
edgeb[52,1]<-2
edgeb[53,1]<-3
edgeb[54,1]<-4
edgeb[55,1]<-5

edgeb[1,2]<-2
edgeb[2,2]<-3
edgeb[3,2]<-4
edgeb[4,2]<-5
edgeb[5,2]<-1

edgeb[51,2]<-3
edgeb[52,2]<-4
edgeb[53,2]<-5
edgeb[54,2]<-1
edgeb[55,2]<-2

edgeb <- data.frame(edgeb)
gb <- graph.data.frame(edgeb,directed=FALSE)

edgec<-matrix(nrow=60,ncol=2)
edgec[1:50,1]<-nodes

for (i in 3:25){
edgec[i,2]<-1
}

for (i in 26:50){
edgec[i,2]<-2
}

edgec[1,2]<-2
edgec[2,2]<-1

edgec[51:60,1]<-nodes[3:12]
edgec[51:60,2]<-nodes[40:49]

edgec <- data.frame(edgec)
gc <- graph.data.frame(edgec,directed=FALSE)
gc<-simplify(gc)




edged<-matrix(nrow=65,ncol=2)
edged[1:50,1]<-nodes

for (i in 6:14){
edged[i,2]<-1
}

for (i in 15:23){
edged[i,2]<-2
}

for (i in 24:32){
edged[i,2]<-3
}

for (i in 33:41){
edged[i,2]<-4
}

for (i in 41:50){
edged[i,2]<-5
}

edged[51,1]<-1
edged[52,1]<-2
edged[53,1]<-3
edged[54,1]<-4
edged[55,1]<-5

edged[1,2]<-2
edged[2,2]<-3
edged[3,2]<-4
edged[4,2]<-5
edged[5,2]<-1

edged[51,2]<-3
edged[52,2]<-4
edged[53,2]<-5
edged[54,2]<-1
edged[55,2]<-2


edged[56:59,1]<-nodes[6:9]
edged[56,2]<-15
edged[57,2]<-24
edged[58,2]<-33
edged[59,2]<-41

edged[60:62,1]<-nodes[16:18]
edged[60,2]<-25
edged[61,2]<-34
edged[62,2]<-42

edged[63:64,1]<-nodes[26:27]
edged[63,2]<-35
edged[64,2]<-43

edged[65,1]<-33
edged[65,2]<-44


edged <- data.frame(edged)
gd <- graph.data.frame(edged,directed=FALSE)


labelsa<-c(1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2)
labelsb<-c(1,2,3,4,5,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5)


colora<-c("deepskyblue","orange","deepskyblue","deepskyblue","deepskyblue","deepskyblue","deepskyblue","deepskyblue","deepskyblue","deepskyblue","deepskyblue","deepskyblue","deepskyblue","deepskyblue","deepskyblue","deepskyblue","deepskyblue","deepskyblue","deepskyblue","deepskyblue","deepskyblue","deepskyblue","deepskyblue","deepskyblue","deepskyblue","orange","orange","orange","orange","orange","orange","orange","orange","orange","orange","orange","orange","orange","orange","orange","orange","orange","orange","orange","orange","orange","orange","orange","orange","orange")
colorb<-c("deepskyblue","orange","green","red","yellow","deepskyblue","deepskyblue","deepskyblue","deepskyblue","deepskyblue","deepskyblue","deepskyblue","deepskyblue","deepskyblue","orange","orange","orange","orange","orange","orange","orange","orange","orange","green","green","green","green","green","green","green","green","green","red","red","red","red","red","red","red","red","yellow","yellow","yellow","yellow","yellow","yellow","yellow","yellow","yellow","yellow")

sizea<-c(20,20,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15)
sizeb<-c(20,20,20,20,20,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15)

pdf("Figure 2.pdf", width=6, height=6)

par(mar=c(0,2,0,0.5), mfrow = c(2,2), oma=c(2,0,2,0))

plot(ga,vertex.color=c(colora),vertex.label=c(labelsa),vertex.size=c(sizea),layout=layout.fruchterman.reingold)
mtext("Few Groups",side=3,line=0.7,cex=1.2)
mtext("Highly Fragmented",side=2,line=0.7,cex=1.2)
plot(gb,vertex.color=c(colorb),vertex.label=c(labelsb),vertex.size=c(sizeb),layout=layout.kamada.kawai)
mtext("Many Groups",side=3,line=0.7,cex=1.2)
plot(gc,vertex.color=c(colora),vertex.label=c(labelsa),vertex.size=c(sizea),layout=layout.fruchterman.reingold)
mtext("Less Fragmented",side=2,line=0.7,cex=1.2)
plot(gd,vertex.color=c(colorb),vertex.label=c(labelsb),vertex.size=c(sizeb))

dev.off()












